import { h } from 'vue';
import { NTag } from 'naive-ui';
import { BasicColumn } from '@/components/Table';

const noticeTypeMsg = ['公告', '会议', '其他'];
const receiveTypeMsg = ['全部', '部门'];

export const columns: BasicColumn[] = [
  {
    title: '标题',
    key: 'title',
    width: 450,
  },
  {
    title: '类型',
    key: 'notice_type',
    render(row) {
      return h(
        NTag,
        {
          type: 'default',
        },
        {
          default: () => noticeTypeMsg[row.notice_type - 1],
        },
      );
    },
  },
  {
    title: '接收类型',
    key: 'receive_type',
    render(row) {
      return h(
        NTag,
        {
          type: 'default',
        },
        {
          default: () => receiveTypeMsg[row.receive_type - 1],
        },
      );
    },
  },
  {
    title: '发送者',
    key: 'send_name',
  },
  {
    title: '状态',
    key: 'notice_status',
    render(row) {
      return h(
        NTag,
        {
          type: row.notice_status === 1 ? 'success' : 'warning',
        },
        {
          default: () => (row.notice_status === 1 ? '已发' : '草稿'),
        },
      );
    },
  },
  {
    title: '创建时间',
    key: 'created_at',
  },
];
